﻿using HR.Config;
using HR.Filters;
using HR.IService;
using HR.Models;
using Microsoft.AspNetCore.Mvc;

namespace HR.Controllers
{
    public class JobSetController : Controller
    {
        private readonly IJob_setService jss;

        public JobSetController(IJob_setService jss)
        {
            this.jss = jss;
        }
        [TypeFilter(typeof(RoleFilterAttribute))]
        [HttpGet]
        public IActionResult JobCallSet()
        {
            return View();
        }

        [HttpGet]
        public async Task<IActionResult> JobSetFill()
        {
            Paging<config_public_char> pg = await jss.JobSetFill();
            return Json(pg);
        }
        /// <summary>
        /// 新增职称
        /// </summary>
        /// <param name="cpc"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> JobSetAdd([FromBody] config_public_char cpc)
        {
            int res = await jss.JobSetAdd(cpc);
            return Json(res);
        }
        /// <summary>
        /// 修改职称
        /// </summary>
        /// <param name="cpc"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> JobSetUpdate([FromBody] config_public_char cpc)
        {
            int res = await jss.JobSetUpdate(cpc);
            return Json(res);
        }
        /// <summary>
        /// 删除职称
        /// </summary>
        /// <param name="cpcid"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IActionResult> JobSetDelete(short cpcid)
        {
            int res = await jss.JobSetDelete(cpcid);
            return Json(res);
        }
    }
}
